<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    //黑名单
    protected $guarded=[];
    public function user(){
        return $this->belongsTo('App\User')->withDefault(function ($user){
            $user->name='tom';
        });
    }
    public function comments(){
        return $this->hasMany('App\Comment')->orderBy('created_at','desc');
    }
}
